package weaver.interfaces.zhlx.duss.action.hrmresourcemodule.hcm;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.weaver.general.BaseBean;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.interfaces.zhlx.duss.utils.HcmUtil;
import weaver.soa.workflow.request.RequestInfo;

import java.util.HashMap;
import java.util.Map;

/**
 * @Title: ecology-idea
 * @Company: 泛微软件
 * @author: weaver.Dusongsong
 * @version: 1.0
 * @CreateDate: 2023-12-06
 * @Description: 员工服务中心-员工信息登记表流程调用接口异动流程传输SAP,员工入职接口
 * @ModifyLog:
 **/
public class WeaYgxxdjlcAction extends BaseBean implements Action {
    @Override
    public String execute(RequestInfo requestInfo) {
        String requestid = requestInfo.getRequestid();
        String tablename = requestInfo.getRequestManager().getBillTableName();
        String src = requestInfo.getRequestManager().getSrc();
        writeLog(">>>>>WeaYgxxdjlcAction>>>>>requestid=" + requestid);
        try {
            String message = "调用HCM系统接口返回:";
            RecordSet rs = new RecordSet();
            HcmUtil hcmUtil = new HcmUtil();
            rs.executeQuery("select * from " + tablename + " where requestid=?", requestid);
            rs.next();
            String mainid = Util.null2String(rs.getString("id"));
            String sfrzcg = Util.null2String(rs.getString("sfrzcg"));
            String gh = Util.null2String(rs.getString("gh"));
            String dbdwsj = hcmUtil.formatDate(Util.null2String(rs.getString("dbdwsj")));
            String czlx = Util.null2String(rs.getString("czlx"));
            String rzlx1 = Util.null2String(rs.getString("rzlx1"));
            String gsmcrsfw = Util.null2String(rs.getString("gsmcrsfw"));
            String rszfwwb = Util.null2String(rs.getString("rszfwwb"));
            String ygz = Util.null2String(rs.getString("ygz"));
            String ygzz = Util.null2String(rs.getString("ygzz"));
            String lbbj = Util.null2String(rs.getString("lbbj"));
            String gzfw = Util.null2String(rs.getString("gzfw"));
            String gw = Util.null2String(rs.getString("gw"));
            String htzt1 = Util.null2String(rs.getString("htzt1"));
            String sbzt = Util.null2String(rs.getString("sbzt"));
            String gzhszt = Util.null2String(rs.getString("gzhszt"));
            String zd = Util.null2String(rs.getString("zd"));
            String srl = Util.null2String(rs.getString("srl"));
            String syqzt = Util.null2String(rs.getString("syqzt"));
            String tclrylb = Util.null2String(rs.getString("tclrylb"));
            String std = Util.null2String(rs.getString("std"));
            String cj = Util.null2String(rs.getString("cj"));
            String gps = Util.null2String(rs.getString("gps"));
            String zpzl = Util.null2String(rs.getString("zpzl"));
            String zpfs = Util.null2String(rs.getString("zpfs"));
            String zpqd = Util.null2String(rs.getString("zpqd"));
            String sfjhwzp = Util.null2String(rs.getString("sfjhwzp"));
            String x = Util.null2String(rs.getString("x"));
            String m = Util.null2String(rs.getString("m"));
            String ywmnc = Util.null2String(rs.getString("ywmnc"));
            String xb = Util.null2String(rs.getString("xb"));
            String csrq = Util.null2String(rs.getString("csrq"));
            String gjbm = Util.null2String(rs.getString("gjbm"));
            String hyzk = Util.null2String(rs.getString("hyzk"));
            String hkxz = Util.null2String(rs.getString("hkxz"));
            String mz = Util.null2String(rs.getString("mz"));
            String jg = Util.null2String(rs.getString("jg"));
            String csd = Util.null2String(rs.getString("csd"));
            String jkzk = Util.null2String(rs.getString("jkzk"));
            String rsdaszd = Util.null2String(rs.getString("rsdaszd"));
            String gwzt = Util.null2String(rs.getString("gwzt"));
            String sccbsj = Util.null2String(rs.getString("sccbsj"));
            String rzhtxsj = Util.null2String(rs.getString("rzhtxsj"));
            String sjhm1 = Util.null2String(rs.getString("sjhm1"));
            String sjhm2 = Util.null2String(rs.getString("sjhm2"));
            String dzyx = Util.null2String(rs.getString("dzyx"));
            String htsxrq = hcmUtil.formatDate(Util.null2String(rs.getString("htsxrq")));
            String hth = Util.null2String(rs.getString("hth"));
            String htlx = Util.null2String(rs.getString("htlx"));
            String htzzrq = hcmUtil.formatDate(Util.null2String(rs.getString("htzzrq")));
            String htqxfl = Util.null2String(rs.getString("htqxfl"));
            String htqxn = Util.null2String(rs.getString("htqxn"));
            String syqxy = Util.null2String(rs.getString("syqxy"));
            String sydqr = hcmUtil.formatDate(Util.null2String(rs.getString("sydqr")));
            String htgwlx = Util.null2String(rs.getString("htgwlx"));
            String htzt = Util.null2String(rs.getString("htzt"));
            String htqdzt = Util.null2String(rs.getString("htqdzt"));
            String sffpzhdxzh = Util.null2String(rs.getString("sffpzhdxzh"));
            JSONArray ydDataList = new JSONArray();
            JSONObject ydDataJson = new JSONObject();
            ydDataJson.put("UUID", hcmUtil.getUUID16Str());
            ydDataJson.put("PERNR", gh);
            ydDataJson.put("BEGDA", dbdwsj);
            ydDataJson.put("MASSN", czlx);
            ydDataJson.put("MASSG", rzlx1);
            ydDataJson.put("WERKS", gsmcrsfw);
            ydDataJson.put("BTRTL", rszfwwb);
            ydDataJson.put("PERSG", ygz);
            ydDataJson.put("PERSK", ygzz);
            ydDataJson.put("ZTERF", lbbj);
            ydDataJson.put("ABKRS", gzfw);
            ydDataJson.put("PLANS", gw);
            ydDataJson.put("SACHP", htzt1);
            ydDataJson.put("SACHZ", sbzt);
            ydDataJson.put("SACHA", gzhszt);
            ydDataJson.put("ZZGWZD", zd);
            ydDataJson.put("ZHR_SRL", srl);
            ydDataJson.put("ZZSYZT", syqzt);
            ydDataJson.put("ZZTCLRYLB", tclrylb);
            ydDataJson.put("ZHR_STD", std);
            ydDataJson.put("ZHR_ZWCJ", cj);
            ydDataJson.put("ZZZGPS", gps);
            ydDataJson.put("ZZGWZT", gwzt);
            ydDataList.add(ydDataJson);
            writeLog(">>>>>WeaYgxxdjlcAction>>>>>ydDataList=" + ydDataList);
            Map<String, Object> dataMap = new HashMap<>();
            dataMap.put("jkdymc", "WeaYgxxdjlcAction");
            dataMap.put("lcid", requestid);
            dataMap.put("dylc", requestid);
            dataMap.put("cz", src);
            if (!"0".equals(sfrzcg)) {
                JSONObject resultJson = hcmUtil.handleOKHttpRequest("EC201", ydDataList, dataMap);
                writeLog(">>>>>WeaYgxxdjlcAction>>>>>resultJson=" + resultJson);
                String code = Util.null2String(resultJson.getString("code"));
                if ("success".equals(code)) {
                    String output = Util.null2String(resultJson.getString("OUTPUT"));
                    JSONObject outputJson = JSONObject.parseObject(output);
                    String msgType = outputJson.getString("MSG_TYPE");
                    if (!"S".equals(msgType)) {
                        message += outputJson.getString("MSG_TEXT");
                        String returnData = outputJson.getString("DATA");
                        JSONArray returnDataList = JSONArray.parseArray(returnData);
                        for (int i = 0; i < returnDataList.size(); i++) {
                            String type = returnDataList.getJSONObject(i).getString("TYPE");
                            if ("E".equalsIgnoreCase(type)) {
                                message += returnDataList.getJSONObject(i).getString("MESSAGE");
                            }
                        }
                        requestInfo.getRequestManager().setMessageid("111111");
                        requestInfo.getRequestManager().setMessagecontent(message);
                        return Action.FAILURE_AND_CONTINUE;
                    } else {
                        rs.executeUpdate("update " + tablename + " set sfrzcg=0 where requestid=?", requestid);
                    }
                } else {
                    message += Util.null2String(resultJson.getString("message"));
                    requestInfo.getRequestManager().setMessageid("111111");
                    requestInfo.getRequestManager().setMessagecontent(message);
                    return Action.FAILURE_AND_CONTINUE;
                }
            }
            JSONArray xgDataList = new JSONArray();
            JSONObject xgDataJson = new JSONObject();
            xgDataJson.put("PERNR", gh);
            JSONArray P9001List = new JSONArray();
            JSONObject P9001Json = new JSONObject();
            P9001Json.put("BEGDA", dbdwsj);
            P9001Json.put("ENDDA", "99991231");
            P9001Json.put("ZHR_ZPZL", zpzl);
            P9001Json.put("ZHR_ZPFS", zpfs);
            P9001Json.put("ZHR_ZPQD", zpqd);
            if ("0".equals(sfjhwzp)) {
                P9001Json.put("ZHR_ZPLX", "X");
            }
            P9001Json.put("ZHGUID", hcmUtil.getUUIDStr());
            P9001Json.put("ACTION", "I");
            P9001List.add(P9001Json);
            xgDataJson.put("P9001", P9001List);
            JSONArray P0002List = new JSONArray();
            JSONObject P0002Json = new JSONObject();
            P0002Json.put("BEGDA", hcmUtil.formatDate(csrq));
            P0002Json.put("ENDDA", "99991231");
            P0002Json.put("NACHN", x);
            P0002Json.put("VORNA", m);
            P0002Json.put("NAME2", ywmnc);
            P0002Json.put("GESCH", xb);
            P0002Json.put("GBDAT", hcmUtil.formatDate(csrq));
            P0002Json.put("NATIO", gjbm);
            P0002Json.put("FAMST", hyzk);
            P0002Json.put("ZZHUKOT", hkxz);
            P0002Json.put("ZZMZ", mz);
            P0002Json.put("ZZJG", jg);
            P0002Json.put("ZZCSD", csd);
            P0002Json.put("ZZJKZK", jkzk);
            P0002Json.put("ZZRSDA", rsdaszd);
            if ("1".equals(sffpzhdxzh)) {
                P0002Json.put("ZZSFZH", sffpzhdxzh);
            }
            P0002Json.put("ZHGUID", hcmUtil.getUUIDStr());
            P0002Json.put("ACTION", "I");
            P0002List.add(P0002Json);
            xgDataJson.put("P0002", P0002List);
            JSONArray P0006List = new JSONArray();
            rs.executeQuery("select * from " + tablename + "_dt11 where mainid=?", mainid);
            while (rs.next()) {
                String dzlx = Util.null2String(rs.getString("dzlx"));
                String province = Util.null2String(rs.getString("province"));
                String city = Util.null2String(rs.getString("city"));
                String qx = Util.null2String(rs.getString("qx"));
                String xxdz = Util.null2String(rs.getString("xxdz"));
                JSONObject P0006Json = new JSONObject();
                P0006Json.put("BEGDA", dbdwsj);
                P0006Json.put("ENDDA", "99991231");
                P0006Json.put("ANSSA", dzlx);
                P0006Json.put("ZHR_SF", province);
                P0006Json.put("ZHR_CS", city);
                P0006Json.put("ZHR_QX", qx);
                P0006Json.put("STRAS", xxdz);
                P0006Json.put("ZHGUID", hcmUtil.getUUIDStr());
                P0006Json.put("ACTION", "I");
                P0006List.add(P0006Json);
            }
            xgDataJson.put("P0006", P0006List);
            JSONArray P0009List = new JSONArray();
            JSONArray P0041List = new JSONArray();
            JSONArray P0105List = new JSONArray();
            rs.executeQuery("select * from " + tablename + "_dt13 where mainid=?", mainid);
            while (rs.next()) {
                JSONObject P0009Json = new JSONObject();
                P0009Json.put("BEGDA", dbdwsj);
                P0009Json.put("ENDDA", "99991231");
                P0009Json.put("BANKS", Util.null2String(rs.getString("gjdm")));
                P0009Json.put("BANKL", Util.null2String(rs.getString("yxdm")));
                String yxzh = Util.null2String(rs.getString("yxzh"));
                P0009Json.put("ZLSCH", "T");
                P0009Json.put("BNKSA", "0");
                P0009Json.put("BANKN", yxzh.length()<=18 ? yxzh : yxzh.substring(0,18));
                P0009Json.put("BKREF", yxzh.length()<=18 ? "" : yxzh.substring(18));
                P0009Json.put("ZHGUID", hcmUtil.getUUIDStr());
                P0009Json.put("ACTION", "I");
                P0009List.add(P0009Json);
            }
            xgDataJson.put("P0009", P0009List);
            JSONObject P0041Json = new JSONObject();
            P0041Json.put("BEGDA", dbdwsj);
            P0041Json.put("ENDDA", "99991231");
            P0041Json.put("DAR05", "Z5");
            P0041Json.put("DAT05", hcmUtil.formatDate(sccbsj));
            P0041Json.put("DAR07", "Z7");
            P0041Json.put("DAT07", hcmUtil.formatDate(rzhtxsj));
            P0041Json.put("ZHGUID", hcmUtil.getUUIDStr());
            P0041Json.put("ACTION", "I");
            P0041List.add(P0041Json);
            xgDataJson.put("P0041", P0041List);
            if (!"".equals(sjhm1)) {
                JSONObject P0105Json = new JSONObject();
                P0105Json.put("BEGDA", dbdwsj);
                P0105Json.put("ENDDA", "99991231");
                P0105Json.put("USRTY", "9001");
                P0105Json.put("USRID", sjhm1);
                P0105Json.put("ZHGUID", hcmUtil.getUUIDStr());
                P0105Json.put("ACTION", "I");
                P0105List.add(P0105Json);
            }
            if (!"".equals(sjhm2)) {
                JSONObject P0105Json = new JSONObject();
                P0105Json.put("BEGDA", dbdwsj);
                P0105Json.put("ENDDA", "99991231");
                P0105Json.put("USRTY", "9002");
                P0105Json.put("USRID", sjhm2);
                P0105Json.put("ZHGUID", hcmUtil.getUUIDStr());
                P0105Json.put("ACTION", "I");
                P0105List.add(P0105Json);
            }
            if (!"".equals(dzyx)) {
                JSONObject P0105Json = new JSONObject();
                P0105Json.put("BEGDA", dbdwsj);
                P0105Json.put("ENDDA", "99991231");
                P0105Json.put("USRTY", "9008");
                P0105Json.put("USRID", dzyx);
                P0105Json.put("ZHGUID", hcmUtil.getUUIDStr());
                P0105Json.put("ACTION", "I");
                P0105List.add(P0105Json);
            }
            xgDataJson.put("P0105", P0105List);
            JSONArray P0534List = new JSONArray();
            rs.executeQuery("select * from " + tablename + "_dt1 where mainid=?", mainid);
            while (rs.next()) {
                JSONObject P0534Json = new JSONObject();
                P0534Json.put("BEGDA", hcmUtil.formatDate(Util.null2String(rs.getString("cjdprq"))));
                P0534Json.put("ENDDA", "99991231");
                P0534Json.put("PCODE", Util.null2String(rs.getString("zzmm")));
                String zzgxsfzzhtxn = Util.null2String(rs.getString("zzgxsfzzhtxn"));
                if ("0".equals(zzgxsfzzhtxn)) {
                    P0534Json.put("ZZGXDW", "X");
                }
                P0534Json.put("ZZDPZZ", hcmUtil.formatDate(Util.null2String(rs.getString("dpzzrq"))));
                P0534Json.put("ZZDPSZDW", Util.null2String(rs.getString("cjdpsszdw")));
                P0534Json.put("ZZJSR", Util.null2String(rs.getString("jsr")));
                P0534Json.put("ZHGUID", hcmUtil.getUUIDStr());
                P0534Json.put("ACTION", "I");
                P0534List.add(P0534Json);
            }
            xgDataJson.put("P0534", P0534List);
            JSONArray P0021List = new JSONArray();
            rs.executeQuery("select * from " + tablename + "_dt2 where mainid=?", mainid);
            while (rs.next()) {
                JSONObject P0021Json = new JSONObject();
                P0021Json.put("BEGDA", dbdwsj);
                P0021Json.put("ENDDA", "99991231");
                P0021Json.put("SUBTY", Util.null2String(rs.getString("ybrdgx")));
                P0021Json.put("FANAM", Util.null2String(rs.getString("x")));
                P0021Json.put("FAVOR", Util.null2String(rs.getString("m")));
                // P0021Json.put("FASEX", Util.null2String(rs.getString("xb")));
                P0021Json.put("FGBDT", hcmUtil.formatDate(Util.null2String(rs.getString("cycsrq"))));
                P0021Json.put("ZZGZDW", Util.null2String(rs.getString("gzdw")));
                P0021Json.put("ZZGW", Util.null2String(rs.getString("zwzw")));
                P0021Json.put("ZZPCODE", Util.null2String(rs.getString("zzmm")));
                P0021Json.put("ZZTELNR", Util.null2String(rs.getString("lxdh")));
                String jjlxr = Util.null2String(rs.getString("jjlxr"));
                if ("0".equals(jjlxr)) {
                    P0021Json.put("ZHR_JJLXR", "X");
                }
                P0021Json.put("ZHGUID", hcmUtil.getUUIDStr());
                P0021Json.put("ACTION", "I");
                P0021List.add(P0021Json);
            }
            xgDataJson.put("P0021", P0021List);
            JSONArray P0185List = new JSONArray();
            rs.executeQuery("select * from " + tablename + "_dt12 where mainid=?", mainid);
            while (rs.next()) {
                JSONObject P0185Json = new JSONObject();
                P0185Json.put("BEGDA", dbdwsj);
                P0185Json.put("ENDDA", "99991231");
                P0185Json.put("ICTYP", Util.null2String(rs.getString("zjlb")));
                P0185Json.put("ICNUM", Util.null2String(rs.getString("zjbh")));
                P0185Json.put("USEFR", hcmUtil.formatDate(Util.null2String(rs.getString("syksrq"))));
                P0185Json.put("USETO", hcmUtil.formatDate(Util.null2String(rs.getString("syjsrq"))));
                P0185Json.put("ZHGUID", hcmUtil.getUUIDStr());
                P0185Json.put("ACTION", "I");
                P0185List.add(P0185Json);
            }
            xgDataJson.put("P0185", P0185List);
            JSONArray P9520List = new JSONArray();
            rs.executeQuery("select * from " + tablename + "_dt3 where mainid=?", mainid);
            while (rs.next()) {
                JSONObject P9520Json = new JSONObject();
                P9520Json.put("BEGDA", hcmUtil.formatDate(Util.null2String(rs.getString("rxsj"))));
                P9520Json.put("ENDDA", "99991231");
                P9520Json.put("ZZZXL", Util.null2String(rs.getString("xl")));
                P9520Json.put("ZZXXFS", Util.null2String(rs.getString("xlxs")));
                P9520Json.put("ZZYXMC", Util.null2String(rs.getString("yxmc")));
                P9520Json.put("ZZYDL", Util.null2String(rs.getString("zylb")));
                P9520Json.put("ZZYMC", Util.null2String(rs.getString("sxzy")));
                P9520Json.put("ZZZXW", Util.null2String(rs.getString("xw")));
                P9520Json.put("ZZXLZS", Util.null2String(rs.getString("xlzsbh")));
                P9520Json.put("ZZXWZS", Util.null2String(rs.getString("xwzsbh")));
                P9520Json.put("ZZZXZ", Util.null2String(rs.getString("xzn")));
                String sfzgxl = Util.null2String(rs.getString("sfzgxl"));
                if ("0".equals(sfzgxl)) {
                    P9520Json.put("ZZGXL", "X");
                }
                String sfzgxw = Util.null2String(rs.getString("sfzgxw"));
                if ("0".equals(sfzgxw)) {
                    P9520Json.put("ZZGXW", "X");
                }
                String sfdyxl = Util.null2String(rs.getString("sfdyxl"));
                if ("0".equals(sfdyxl)) {
                    P9520Json.put("ZZDYXL", "X");
                }
                String sflx = Util.null2String(rs.getString("sflx"));
                if ("0".equals(sflx)) {
                    P9520Json.put("ZZSFLX", "X");
                }
                String sf985211 = Util.null2String(rs.getString("sf985211"));
                P9520Json.put("ZZSFXX", sf985211);
                String xxxs = Util.null2String(rs.getString("xxxs"));
                String bysj = Util.null2String(rs.getString("bysj"));
                P9520Json.put("ZZHDQD", xxxs);
                P9520Json.put("ZHR_BYRQ", hcmUtil.formatDate(bysj));
                P9520Json.put("ZHGUID", hcmUtil.getUUIDStr());
                P9520Json.put("ACTION", "I");
                P9520List.add(P9520Json);
            }
            xgDataJson.put("P9520", P9520List);
            JSONArray P9502List = new JSONArray();
            rs.executeQuery("select * from " + tablename + "_dt7 where mainid=?", mainid);
            while (rs.next()) {
                JSONObject P9502Json = new JSONObject();
                P9502Json.put("BEGDA", hcmUtil.formatDate(Util.null2String(rs.getString("hjsj"))));
                P9502Json.put("ENDDA", "99991231");
                P9502Json.put("ZZHJMC", Util.null2String(rs.getString("hjmc")));
                P9502Json.put("ZZJLLB", Util.null2String(rs.getString("jllb")));
                P9502Json.put("ZZJLJB", Util.null2String(rs.getString("jljb")));
                P9502Json.put("ZZJLLX", Util.null2String(rs.getString("jllx")));
                P9502Json.put("ZZBFDW", Util.null2String(rs.getString("sjjg")));
                P9502Json.put("ZZJLYY", Util.null2String(rs.getString("jlyy")));
                P9502Json.put("ZZFWWH", Util.null2String(rs.getString("fwwh")));
                P9502Json.put("ZHGUID", hcmUtil.getUUIDStr());
                P9502Json.put("ACTION", "I");
                P9502List.add(P9502Json);
            }
            xgDataJson.put("P9502", P9502List);
            JSONArray P9509List = new JSONArray();
            rs.executeQuery("select * from " + tablename + "_dt8 where mainid=?", mainid);
            while (rs.next()) {
                JSONObject P9509Json = new JSONObject();
                P9509Json.put("BEGDA", hcmUtil.formatDate(Util.null2String(rs.getString("qdzgsj"))));
                P9509Json.put("ENDDA", "99991231");
                P9509Json.put("ZZYLB", Util.null2String(rs.getString("zylb")));
                P9509Json.put("ZZCXL", Util.null2String(rs.getString("zyfl")));
                P9509Json.put("ZZYZG", Util.null2String(rs.getString("zyjszwrzzgmc")));
                P9509Json.put("ZZGJB", Util.null2String(rs.getString("zyjsjb")));
                P9509Json.put("ZZGBWH", Util.null2String(rs.getString("gbzgwjh")));
                P9509Json.put("ZZPSDW", Util.null2String(rs.getString("zgpsdw")));
                P9509Json.put("ZZHDTJ", Util.null2String(rs.getString("qdzgtj")));
                String sfzgzc = Util.null2String(rs.getString("sfzgzc"));
                if ("0".equals(sfzgzc)) {
                    P9509Json.put("ZZSFZGZC", "X");
                }
                P9509Json.put("ZHGUID", hcmUtil.getUUIDStr());
                P9509Json.put("ACTION", "I");
                P9509List.add(P9509Json);
            }
            xgDataJson.put("P9509", P9509List);
            JSONArray P9516List = new JSONArray();
            rs.executeQuery("select * from " + tablename + "_dt5 where mainid=?", mainid);
            while (rs.next()) {
                JSONObject P9516Json = new JSONObject();
                P9516Json.put("BEGDA", dbdwsj);
                P9516Json.put("ENDDA", "99991231");
                P9516Json.put("ZZSYZ", Util.null2String(rs.getString("zsyz")));
                P9516Json.put("ZHR_YYZS", Util.null2String(rs.getString("yyzsid")));
                P9516Json.put("ZZSLCD", Util.null2String(rs.getString("yydjid")));
                //P9516Json.put("ZZSMC", Util.null2String(rs.getString("zsmc")));
                P9516Json.put("ZHR_SLCD", Util.null2String(rs.getString("slcd")));
                P9516Json.put("ZHGUID", hcmUtil.getUUIDStr());
                P9516Json.put("ACTION", "I");
                P9516List.add(P9516Json);
            }
            xgDataJson.put("P9516", P9516List);
            JSONArray P9510List = new JSONArray();
            rs.executeQuery("select * from " + tablename + "_dt9 where mainid=?", mainid);
            while (rs.next()) {
                JSONObject P9510Json = new JSONObject();
                P9510Json.put("BEGDA", hcmUtil.formatDate(Util.null2String(rs.getString("qdzgdrq"))));
                P9510Json.put("ENDDA", "99991231");
                P9510Json.put("ZZGMC", Util.null2String(rs.getString("zzyzgmc")));
                P9510Json.put("ZZGBZGWH", Util.null2String(rs.getString("gbzgwjh")));
                P9510Json.put("ZZHFDW", Util.null2String(rs.getString("zshfdwmc")));
                P9510Json.put("ZZZGDJ", Util.null2String(rs.getString("zgdj")));
                P9510Json.put("ZHGUID", hcmUtil.getUUIDStr());
                P9510Json.put("ACTION", "I");
                P9510List.add(P9510Json);
            }
            xgDataJson.put("P9510", P9510List);
            JSONArray P9521List = new JSONArray();
            rs.executeQuery("select * from " + tablename + "_dt4 where mainid=?", mainid);
            while (rs.next()) {
                JSONObject P9521Json = new JSONObject();
                P9521Json.put("BEGDA", hcmUtil.formatDate(Util.null2String(rs.getString("kssj"))));
                P9521Json.put("ENDDA", hcmUtil.formatDate(Util.null2String(rs.getString("jssj"))));
                P9521Json.put("ZGZDW", Util.null2String(rs.getString("gzdw")));
                P9521Json.put("ZGZBM", Util.null2String(rs.getString("bm")));
                P9521Json.put("ZGZZW", Util.null2String(rs.getString("zwzw")));
                P9521Json.put("ZGZZM", Util.null2String(rs.getString("zmr")));
                P9521Json.put("ZZMDH", Util.null2String(rs.getString("lxdh")));
                P9521Json.put("ZHR_GZLL", Util.null2String(rs.getString("gzjllx")));
                P9521Json.put("ZHGUID", hcmUtil.getUUIDStr());
                P9521Json.put("ACTION", "I");
                P9521List.add(P9521Json);
            }
            xgDataJson.put("P9521", P9521List);
            JSONArray P9532List = new JSONArray();
            rs.executeQuery("select * from " + tablename + "_dt14 where mainid=?", mainid);
            while (rs.next()) {
                JSONObject P9532Json = new JSONObject();
                P9532Json.put("BEGDA", hcmUtil.formatDate(Util.null2String(rs.getString("ksrq"))));
                P9532Json.put("ENDDA", "99991231");
                P9532Json.put("ZZSCLXTCL", Util.null2String(rs.getString("sclx")));
                P9532Json.put("ZZCJLBTCL", Util.null2String(rs.getString("sclb")));
                P9532Json.put("ZZZCDJTCL", Util.null2String(rs.getString("cjdj")));
                P9532Json.put("ZZCJZHTCL", Util.null2String(rs.getString("cjrzh")));
                P9532Json.put("ZZBWCDTCL", Util.null2String(rs.getString("bz")));
                P9532Json.put("ZHGUID", hcmUtil.getUUIDStr());
                P9532Json.put("ACTION", "I");
                P9532List.add(P9532Json);
            }
            xgDataJson.put("P9532", P9532List);
            xgDataList.add(xgDataJson);
            writeLog(">>>>>WeaYgxxdjlcAction>>>>>xgDataJson=" + xgDataJson);
            JSONObject resultJson = hcmUtil.handleOKHttpRequest("EC206", xgDataList, dataMap);
            writeLog(">>>>>WeaYgxxdjlcAction>>>>>resultJson=" + resultJson);
            String code = Util.null2String(resultJson.getString("code"));
            if ("success".equals(code)) {
                String output = Util.null2String(resultJson.getString("OUTPUT"));
                JSONObject outputJson = JSONObject.parseObject(output);
                String msgType = outputJson.getString("MSG_TYPE");
                if (!"S".equals(msgType)) {
                    message += outputJson.getString("MSG_TEXT");
                    requestInfo.getRequestManager().setMessageid("111111");
                    requestInfo.getRequestManager().setMessagecontent(message);
                    return Action.FAILURE_AND_CONTINUE;
                }
            } else {
                message += Util.null2String(resultJson.getString("message"));
                requestInfo.getRequestManager().setMessageid("111111");
                requestInfo.getRequestManager().setMessagecontent(message);
                return Action.FAILURE_AND_CONTINUE;
            }

            JSONArray dataList = new JSONArray();
            JSONObject dataJson = new JSONObject();
            dataJson.put("PERNR", gh);
            dataJson.put("BEGDA", htsxrq);
            dataJson.put("ENDDA", "99991231");
            dataJson.put("CTNUM", hth + gh);
            dataJson.put("CTTYP", htlx);
            dataJson.put("ZZCTEDT", htzzrq);
            dataJson.put("ZZHTQXFL", htqxfl);
            dataJson.put("ZZHTQX", htqxn);
            dataJson.put("ZZSYQX", syqxy);
            dataJson.put("ZHR_SYQDQR", sydqr);
            dataJson.put("ZZHTGWLX", htgwlx);
            dataJson.put("ZZHTZT", htzt);
            dataJson.put("ZZJFDW", htqdzt);
            JSONArray P0019List = new JSONArray();
            JSONObject P0019Json = new JSONObject();
            P0019Json.put("PERNR", gh);
            P0019Json.put("BEGDA", htsxrq);
            P0019Json.put("TMART", "Z1");
            P0019Json.put("TERMN", htzzrq);
            P0019List.add(P0019Json);
            dataJson.put("P0019", P0019List);
            dataList.add(dataJson);
            writeLog(">>>>>WeaYgxxdjlcAction>>>>>dataList=" + dataList);
            resultJson = hcmUtil.handleOKHttpRequest("EC202", dataList, dataMap);
            writeLog(">>>>>WeaYgxxdjlcAction>>>>>resultJson=" + resultJson);
            code = Util.null2String(resultJson.getString("code"));
            if ("success".equals(code)) {
                String output = Util.null2String(resultJson.getString("OUTPUT"));
                JSONObject outputJson = JSONObject.parseObject(output);
                String msgType = outputJson.getString("MSG_TYPE");
                if (!"S".equals(msgType)) {
                    message += outputJson.getString("MSG_TEXT");
                    requestInfo.getRequestManager().setMessageid("111111");
                    requestInfo.getRequestManager().setMessagecontent(message);
                    return Action.FAILURE_AND_CONTINUE;
                }
            } else {
                message += Util.null2String(resultJson.getString("message"));
                requestInfo.getRequestManager().setMessageid("111111");
                requestInfo.getRequestManager().setMessagecontent(message);
                return Action.FAILURE_AND_CONTINUE;
            }

            return Action.SUCCESS;
        } catch (Exception e) {
            System.out.println(">>>>>WeaYgxxdjlcAction>>>>>Exception" + e);
            requestInfo.getRequestManager().setMessageid("111111");
            requestInfo.getRequestManager().setMessagecontent("Action接口处理异常,请联系管理员");
            return Action.FAILURE_AND_CONTINUE;
        }
    }
}